package cn.epsilon3.factory;

import cn.epsilon3.domain.e3.po.E3Log;
import cn.epsilon3.utils.SpringContextUtils;
import cn.epsilon3.service.E3LogService;

import java.util.TimerTask;

/**
 * @description 计划调度 TimerTask工厂
 *
 * @author: epsilon3
 * @date: 2023/9/5 11:43
 */
public class E3ScheduledFactory {

    /**
     * 保存日志计划
     *
     * @param e3Log 日志实体
     * @return TimerTask
     */
    public static TimerTask recordLog(final E3Log e3Log) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringContextUtils.getBean(E3LogService.class).saveLog(e3Log);
            }
        };
    }
}
